public class AnimalTest {
    public static void main(String[] args) {
        Animal[] animals = {
            new Dog("小狗", 3, "哈士奇"),
            new Cat("小猫", 2, "白色")
        };

        for (Animal animal : animals) {
            animal.makeSound();
            if (animal instanceof Trainable) {
                ((Trainable) animal).train();
            }
            if (animal instanceof Swimmable) {
                ((Swimmable) animal).swim();
            }
        }
    }
}